/**
 * 获取布局信息
 * @author lian
 */
export const useLayoutInfo = () => {
  // 获取系统信息
  const { statusBarHeight, safeAreaInsets, screenHeight, windowHeight } = uni.getSystemInfoSync()
  // 获取菜单按钮布局信息
  const { top, height } = uni.getMenuButtonBoundingClientRect()

  /**
   * 导航栏高度
   */
  const navBarHeight = computed(() => {
    return (top - statusBarHeight!) * 2 + height
  })

  /**
   * 内容距离顶部边距
   */
  const topPadding = computed(() => {
    return navBarHeight.value + safeAreaInsets!.top
  })

  /**
   * 内容高度
   */
  const contentAreaHeight = ref(screenHeight - topPadding.value)

  /**
   * tabbar 高度
   */
  const tabBarHeight = computed(() => screenHeight - windowHeight)

  /**
   * 顶部安全区
   */
  const safeTop = ref(safeAreaInsets?.top)

  /**
   * 底部安全区
   */
  const safeBottom = ref(safeAreaInsets?.bottom)

  return {
    navBarHeight,
    topPadding,
    contentAreaHeight,
    tabBarHeight,
    safeTop,
    safeBottom,
  }
}
